//
//  SKRetrieveCodeView.m
//  SKaURobot
//
//  Created by cdong on 16/2/19.
//  Copyright © 2016年 cdong. All rights reserved.
//

#import "SKRetrieveCodeView.h"

@implementation SKRetrieveCodeView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setView];
    }
    return self;
}

- (void)loadNagavitionViewWithString:(NSString *)nameString{

    self.navigationV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 375*matchW, 64)];
    self.navigationV.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bg"]];
    [self addSubview:self.navigationV];
    self.navigationVL = [[UILabel alloc]initWithFrame:CGRectMake(((self.frame.size.width - 100)/2), 20, 100, 44)];
    self.navigationVL.text = nameString;
    self.navigationVL.textAlignment = NSTextAlignmentCenter;
    self.navigationVL.textColor = [RGBColorEncapsulation colorWithRGB:0xf8f8f8 alpha:1];
    self.navigationVL.font = [UIFont systemFontOfSize:19];
    [self.navigationV addSubview:self.navigationVL];
    
    self.backBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.backBtn.frame = CGRectMake(12*matchW, CGRectGetMinY(self.navigationVL.frame) + 7, 30, 30);
    [self.backBtn setBackgroundImage:[UIImage imageNamed:@"2left"] forState:UIControlStateNormal];
    [self.navigationV addSubview:self.backBtn];
}

- (void)setView{
    [self loadNagavitionViewWithString:@"新密码"];
    UIView *mainView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.navigationV.frame), 375*matchW, self.frame.size.height - CGRectGetMaxY(self.navigationV.frame))];
    //????
    mainView.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xf4f4f4 alpha:1];
    [self addSubview:mainView];
    
    self.pwdImageV = [[UIImageView alloc]initWithFrame:CGRectMake((12+13.5)*matchW, (17+15)*matchH, 26*matchW, 26*matchH)];
    self.pwdImageV.image = [UIImage imageNamed:@"icon_lock"];
    [mainView addSubview:self.pwdImageV];
    
    self.pwdTF = [[UITextField alloc]initWithFrame:CGRectMake(65*matchW, 17*matchH, self.frame.size.width - 53*matchW - 12*matchW, 60*matchH)];
    if ([self.pwdTF respondsToSelector:@selector(setAttributedPlaceholder:)]) {
        UIColor *color = [RGBColorEncapsulation colorWithRGB:0xbab9ba alpha:1];
        UIFont *font = [UIFont systemFontOfSize:15];
        self.pwdTF.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"请输入新密码" attributes:@{NSForegroundColorAttributeName:color,NSFontAttributeName:font}];
    }
    self.pwdTF.secureTextEntry = YES;
    [mainView addSubview:self.pwdTF];
    
    self.pwdBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.pwdBtn.frame = CGRectMake(CGRectGetMaxX(self.pwdTF.frame) - 18*matchW - 30*matchW, CGRectGetMinY(self.pwdImageV.frame)+4*matchH, 26*matchW, 26*matchH);
    [self.pwdBtn setBackgroundImage:[UIImage imageNamed:@"icon_eye"] forState:UIControlStateNormal];
    [mainView addSubview:self.pwdBtn];
    
    self.fillV = [[UIView alloc]initWithFrame:CGRectMake(12*matchW, CGRectGetMaxY(self.pwdTF.frame), self.frame.size.width - 24*matchW, 1*matchH)];
    self.fillV.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xe6e6e6 alpha:1];
    [mainView addSubview:self.fillV];
    
    self.pwdNextImageV = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.pwdImageV.frame), CGRectGetMaxY(self.fillV.frame) + 15, CGRectGetWidth(self.pwdImageV.frame), CGRectGetHeight(self.pwdImageV.frame))];
    self.pwdNextImageV.image = [UIImage imageNamed:@"icon_lock"];
    [mainView addSubview:self.pwdNextImageV];
    
    self.pwdNextTF = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.pwdTF.frame), CGRectGetMaxY(self.fillV.frame), CGRectGetWidth(self.pwdTF.frame), CGRectGetHeight(self.pwdTF.frame))];
    if ([self.pwdNextTF respondsToSelector:@selector(setAttributedPlaceholder:)]) {
        UIColor *color = [RGBColorEncapsulation colorWithRGB:0xbab9ba alpha:1];
        UIFont *font = [UIFont systemFontOfSize:15];
        self.pwdNextTF.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"再次输入新密码" attributes:@{NSForegroundColorAttributeName:color,NSFontAttributeName:font}];
    }
    self.pwdNextTF.secureTextEntry = YES;
    [mainView addSubview:self.pwdNextTF];
   
    self.pwdNextBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.pwdNextBtn.frame = CGRectMake(CGRectGetMaxX(self.pwdNextTF.frame) - 18*matchW - 30*matchW, CGRectGetMinY(self.pwdNextImageV.frame)+4*matchH, 26*matchW, 26*matchH);
    [self.pwdNextBtn setBackgroundImage:[UIImage imageNamed:@"icon_eye"] forState:UIControlStateNormal];
    [mainView addSubview:self.pwdNextBtn];
   
    self.fillV2 = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.fillV.frame), CGRectGetMaxY(self.pwdNextTF.frame), CGRectGetWidth(self.fillV.frame), CGRectGetHeight(self.fillV.frame))];
    self.fillV2.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xe6e6e6 alpha:1];
    [mainView addSubview:self.fillV2];
    
    self.oKBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.oKBtn.userInteractionEnabled = NO;
    self.oKBtn.frame = CGRectMake(12*matchW, CGRectGetMaxY(self.fillV2.frame)+30*matchH, self.frame.size.width - 24*matchH, 45*matchH);
    self.oKBtn.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xcc222a alpha:1];
    [self.oKBtn setTitle:@"确定" forState:UIControlStateNormal];
    self.oKBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.oKBtn setTitleColor:[RGBColorEncapsulation colorWithRGB:0xffffff alpha:.5] forState:UIControlStateNormal];
    [self.oKBtn.layer setMasksToBounds:YES];
    [self.oKBtn.layer setCornerRadius:3];
    [mainView addSubview:self.oKBtn];
}

@end
